home *** CD-ROM | disk | FTP | other *** search
/ ADA Programming Guide / ADA Programming Guide.iso / ada_gwu / itime.c < prev    next >
C/C++ Source or Header  |  1996-01-30  |  1KB  |  29 lines

  1. /************************************************************************/
  2. /*    Procedure:    itime()                        */
  3. /*    Purpose:        This routine is a rewrite of the itime routine  */
  4. /*            in NYU AdaEd to allow for delays which are     */
  5. /*            dependent on the machine clock cycle (pseudo    */
  6. /*            time), not real time                */
  7. /************************************************************************/
  8.  
  9. #include mon_ext.h
  10.  
  11. long itime()                             /*;itime*/
  12. {
  13.         long  itim;
  14.         /* find elapsed seconds, convert to milliseconds, and add offset 
  15.      *  for midnight corresponding to desired origin
  16.      */
  17.     if ( type_of_delay == 1 )
  18.         start_time = 0;
  19.         else
  20.     {
  21.             clock_t time_now;
  22.             time_now = clock() * (long) ms_per_tick;
  23.             /* adjust for passing midnight if necessary */
  24.             if (time_now < start_time) time_now = time_now + 86400000L ;
  25.             itim =   (long) (time_now - start_time);
  26.             return itim + since_midnight;
  27.     }
  28. }
  29.